package edu.ynu.se.xiecheng.achitectureclass.dao;

import edu.ynu.se.xiecheng.achitectureclass.common.dao.LogicDAO;
import edu.ynu.se.xiecheng.achitectureclass.dto.DataDTO;
import edu.ynu.se.xiecheng.achitectureclass.entity.CO2DataEntity;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;

import java.util.List;


public interface CO2DataDao extends LogicDAO<CO2DataEntity, Long> {

    @Query("SELECT new edu.ynu.se.xiecheng.achitectureclass.dto.DataDTO(cd.id, cd.createTime, cd.dataValue) " +
            "FROM CO2DataEntity cd WHERE cd.isDeleted = 0 ORDER BY cd.createTime DESC")
    List<DataDTO> findLatestTenCO2Data(Pageable pageable);
}
